<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common/hello-common-head.jsp"%>

		<div class="main-container-inner">
			<a class="menu-toggler" id="menu-toggler" href="#"> <span
				class="menu-text"></span>
			</a>
			<div class="sidebar" id="sidebar">
				<script type="text/javascript">
					try {
						ace.settings.check('sidebar', 'fixed')
					} catch (e) {
					}
				</script>
				<div class="sidebar-shortcuts" id="sidebar-shortcuts">
					<div class="sidebar-shortcuts-large" id="sidebar-shortcuts-large">
						<button class="btn btn-success">
							<i class="icon-signal"></i>
						</button>
						<button class="btn btn-info">
							<i class="icon-pencil"></i>
						</button>
						<button class="btn btn-warning">
							<i class="icon-group"></i>
						</button>
						<button class="btn btn-danger">
							<i class="icon-cogs"></i>
						</button>
					</div>
					<div class="sidebar-shortcuts-mini" id="sidebar-shortcuts-mini">
						<span class="btn btn-success"></span> <span class="btn btn-info"></span>
						<span class="btn btn-warning"></span> <span class="btn btn-danger"></span>
					</div>
				</div>
				<!-- #sidebar-shortcuts -->
				<ul class="nav nav-list">
					<li class="open" ><a href="#" class="dropdown-toggle"> <i
							class="icon-desktop"></i> <span class="menu-text"> 工单管理 </span> <b
							class="arrow icon-angle-down"></b>
					</a>
						<ul class="submenu" style="display: block;">
							<li ><a
								href="${pageContext.request.contextPath}/workbase/searchbase">
									<i class="icon-double-angle-right"></i> 基础服务
							</a></li>
							<li ><a href="${pageContext.request.contextPath}/workbase/reportgenerate"> <i
									class="icon-double-angle-right"></i> 报表生成
							</a></li>
							<li class = "active"><a href="${pageContext.request.contextPath}/workbase/dailyreportgenerate"> <i
									class="icon-double-angle-right"></i> 日报报表生成
							</a></li>
							<li><a href="#"> <i
									class="icon-double-angle-right"></i> 其他功能
							</a></li>
						</ul></li>
					<li><a href="#" class="dropdown-toggle"> <i
							class="icon-desktop"></i> <span class="menu-text"> 其他需求 </span> <b
							class="arrow icon-angle-down"></b>
					</a>
						<ul class="submenu">
							<li><a href="#" > <i
									class="icon-double-angle-right"></i> 工单管理
							</a></li>
							<li><a href="#"> <i
									class="icon-double-angle-right"></i> 其他需求
							</a></li>
						</ul></li>
				</ul>
				<!-- /.nav-list -->
				<div class="sidebar-collapse" id="sidebar-collapse">
					<i class="icon-double-angle-left"
						data-icon1="icon-double-angle-left"
						data-icon2="icon-double-angle-right"></i>
				</div>
				<script type="text/javascript">
					try {
						ace.settings.check('sidebar', 'collapsed')
					} catch (e) {
					}
				</script>
			</div>
			<div class="main-content">
				<div class="breadcrumbs" id="breadcrumbs">
					<script type="text/javascript">
						try {
							ace.settings.check('breadcrumbs', 'fixed')
						} catch (e) {
						}
					</script>
					<ul class="breadcrumb">
						<li><i class="icon-home home-icon"></i> <a href="${pageContext.request.contextPath}/iuser/hello">控制台</a>
						</li>
						<li class="active">日报报表生成</li>
					</ul>
				</div>
				

<div class="page-content">
	<!-- <div class="page-header">
			<h1>
				<small>
					<i style="text-align:left">业务类型 :
							<select id="sec_trade_type">
								<option value="0">全部</option>
								<option value="1">机票</option>
								<option value="2">酒店</option>
							</select>
					</i>
				</small>
				<small>
					<i style="text-align:center">工单类型 :
						<select id="sec_ws_type">
								<option value="0">全部</option>
								<option value="1">退款方面</option>
								<option value="2">支付方面</option>
								<option value="3">账户咨询</option>
								<option value="4">咨询返现</option>
								<option value="5">实名问题</option>
								<option value="6">错误工单</option>
								<option value="7">其他</option>
						</select>
					</i>
				</small>
				<small>
					<i style="text-align:right">工单细分 :
						<select id="sec_ws_detail">
								<option value="0">全部</option>
						</select>
					</i>
				</small>
				<small>
					<i style="text-align:right">日期 <input type="date" id="intim" value=""/></i>
				</small>
			</h1>
			<h1>&nbsp</h1>
			<h1>
				<small>
					<i>处理人:
						<select id="sec_deal_person">
								<option value="0">全部</option>
								<option value="1">李成博</option>
								<option value="2">王进洛</option>
								<option value="3">李瑞昊</option>
								<option value="4">赵佳琪</option>
						</select>
					</i>
				</small>
				<small>
					<button style="background-color:blue;color: white" onclick ="sendEmail()">发送邮件</button>
				</small>
				<small>
					<button style="background-color:blue;color: white" onclick ="secWSNum()">生成</button>
				</small>
				<small>
					<button style="background-color:blue;color: white"  onclick="empSecCondition()">清空</button>
				</small>
			</h1>
			<h1>&nbsp</h1>
			<h1>
				<small>
					<i>请填写邮件备注：<input type="text" id="commentAdded"/>
					<input id ="random_1" name="msg1" type="hidden" value=""/>
					<input id ="random_2" name="msg2" type="hidden" value=""/>
					</i>
				</small>
				
			</h1>
	</div>  -->
	<div class="row">
		<div class="col-xs-12">
		<div class="row">
						<div class="col-sm-3" align="center">
							业务类型 :&nbsp;<select name="sec_trade_type" id="sec_trade_type"
								style="width: 200px;">
								<option value="0">全部</option>
								<option value="1">机票</option>
								<option value="2">酒店</option>
							</select>
						</div>
						<div class="col-sm-3" align="center">
							工单类型：&nbsp;<select name="sec_ws_type" id="sec_ws_type"
								style="width: 200px;">
								<option value="0" selected="selected">全部</option>
								<option value="1">退款方面</option>
								<option value="2">支付方面</option>
								<option value="3">账户咨询</option>
								<option value="4">咨询返现</option>
								<option value="5">实名问题</option>
								<option value="6">错误工单</option>
								<option value="7">其他</option>
							</select>
						</div>
						<div class="col-sm-3" align="center">
							工单细分：&nbsp;<select name="sec_ws_detail" id="sec_ws_detail"
								style="width: 200px;">
								<option value="0">全部</option>
							</select>
						</div>
					</div>
					
					<div class="space-12"></div>
						<div class="row">
							<div class="col-sm-3" align="center">
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;日期:&nbsp;<input type="date" id="intim" value=""
								style="width: 200px;" />
						</div>
							<div class="col-sm-3" align="center">
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;处理人:&nbsp;<select name="sec_deal_person" id="sec_deal_person"
								style="width: 200px;">
								<option value="0">全部</option>
								<option value="1">李成博</option>
								<option value="2">王进洛</option>
								<option value="3">李瑞昊</option>
								<option value="4">赵佳琪</option>
							</select>
						</div>
						<div class="col-sm-3" align="center">
					<button class="btn btn-sm btn-primary"  onclick ="secWSNum()">生成</button>
					<button class="btn btn-sm btn-primary"   onclick="empSecCondition()">清空</button>
					<button class="btn btn-sm btn-primary"  onclick ="sendEmail()">发送邮件</button>
					<input id ="random_1" name="msg1" type="hidden" value=""/>
					<input id ="random_2" name="msg2" type="hidden" value=""/>
					<input type="text" id="commentAdded" placeholder="请填写邮件备注" style="height: 35px;width: 200px;"/>
						</div>
						
					</div>
					<div class="space-12"></div>
		
		
			<div class="table-responsive">
				<table id="sample-table-1" class="table table-striped table-bordered table-hover">
					<tbody>
						<tr>
							<td id="chart">
							</td>
						</tr>
					</tbody>
				</table>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-xs-12">
			<div class="table-responsive">
				<table id="sample-table-1" class="table table-striped table-bordered table-hover">
					<tbody>
						<tr>
							<td id="ws_num">
							</td>
						</tr>
					</tbody>
				</table>
			</div>
		</div>
	</div>
</div>
</div>
				<!-- /.main-content -->
</div>
<%@ include file="../common/hello-common-tail.jsp"%>
<script type="text/javascript">
$(function() {
		secWSNum();
	});
function secWSNum(){
	//初始化系统时间
		gencurrentdate();
		var initTim = $("#intim").val();
		var secTradeType = $("#sec_trade_type").val();
		var secWsType = $("#sec_ws_type").val();
		var secWsDetail = $("#sec_ws_detail").val();
		var secDealPerson = $("#sec_deal_person").val();

		var conditionData = {
			"initTim" : initTim,
			"secWsType" : secWsType,
			"secWsDetail" : secWsDetail,
			"secTradeType" : secTradeType,
			"secDealPerson" : secDealPerson
		}
		$.ajax({
					type : "GET",
					url : "${pageContext.request.contextPath}/workbase/generatwschart",
					async : false,
					data : conditionData,
					success : function(result) {
						alert("报表生成");
						loadpictrue(result);
					},
					error : function() {
						alert("没有数据或者数据查询失败");
					}
				});
};
/**
 * 加载报表
 */
function loadpictrue(result){
	var data = result.data;
	$("#chart").empty();
	$("#chart").append('<img src="${pageContext.request.contextPath}/images/chart/chart_'+data.random_1+'.jpeg"/>');
	$("#ws_num").empty();
	$("#ws_num").append('<img src="${pageContext.request.contextPath}/images/chart/ws_num_'+data.random_2+'.jpeg"/>');
	//图片名称缓存起来
	$('#random_1').val(data.random_1);
	$('#random_2').val(data.random_2);
};
/**
 * 清空查询条件
 */
function empSecCondition(){
	var sysDate = new Date();
	var sysYear = sysDate.getFullYear();
	var sysMonth = sysDate.getMonth()+1;
	var sysDay_f = sysDate.getDate();
	if(parseInt(sysDay_f)<10){
		var sysDay_t = 0+""+sysDay_f;
	}else{
		var sysDay_t = sysDay_f;
	}
    $("#intim").val(sysYear+"-"+sysMonth+"-"+sysDay_t);

	$("#sec_trade_type").val("0");
	$("#sec_deal_person").val("0");
	$("#sec_ws_type").val("0");
	$("#sec_ws_detail").val("0");
}
//初始化为当前系统时间
function gencurrentdate(){
	var initTim =$("#intim").val();
	
	var sysDate = new Date();
	var sysYear = sysDate.getFullYear();
	var sysMonth = sysDate.getMonth()+1;
	var sysDay_f = sysDate.getDate();
	if(parseInt(sysDay_f)<10){
		var sysDay_t = 0+""+sysDay_f;
	}else{
		var sysDay_t = sysDay_f;
	}
	if(initTim==null || initTim==undefined || initTim == ''){
		$("#intim").val(sysYear+"-"+sysMonth+"-"+sysDay_t);
	}
};
//发送邮件
function sendEmail(){
	var chart_comment = $("#commentAdded").val();
	var random_1 = $("#random_1").val();
	var random_2 = $("#random_2").val();
	$.ajax({
		type:"GET",
		url:"${pageContext.request.contextPath}/workbase/sendemail",
		data:{'chart_comment':chart_comment,'random_1':random_1,'random_2':random_2},
		success:function(result){
			alert("邮件发送成功");
		},
		error : function() {
			alert("邮件发送失败");
		}
	});
};
jQuery(function($) {
	$("#sec_ws_type").change(function(){
		var ws_type = $("#sec_ws_type").val(); 
		$.ajax({
			type:"GET",
			url:"${pageContext.request.contextPath}/workbase/secwsdetail",
			data:{'ws_type':ws_type},
			success:function(result){
				var data = result.data;
				if(data!= null && data.length >0){
					var option_add ="";
					for(var i=0;i<data.length;i++){
						option_add +=" <option value='"+data[i].type+"'>"+data[i].value+"</option>";
					}
					$("#sec_ws_detail").empty();
					$("#sec_ws_detail").append(option_add);
				}
			},
			error : function() {
				alert("没有数据或者数据查询失败");
			}
		});
		
	});
});
</script>
